package com.ctbri.gui;

import javax.swing.*;

import com.ctbri.arrays.RandomGenerator;
import com.ctbri.util.Generator;
import com.ctbri.util.SwingConsole;

import java.awt.*;
import java.awt.event.*;

public class Ex14_TextPane extends JFrame {
  private JButton b = new JButton("Add Text");
  private JTextArea tp = new JTextArea();
  private static Generator<String> sg =
    new RandomGenerator.String(7);
  public Ex14_TextPane() {
    b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        for(int i = 1; i < 10; i++)
          tp.setText(tp.getText() + sg.next() + "\n");
      }
    });
    add(new JScrollPane(tp));
    add(BorderLayout.SOUTH, b);
  }
  public static void main(String[] args) {
    SwingConsole.run(new Ex14_TextPane(), 475, 425);
  }
} ///:~
